/// @tags: MaxFlow LinerMath
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

namespace BlueQuantum {

int const N = 3e2 + 5, INF = 0x3f3f3f3f;
double const eps = 1e-10;

int n, s, t;
int e_cnt = 1, heads[N << 1], dis[N << 1], cur[N << 1], f[N << 1], vis[N << 1];
double a[N << 1][N], c[N << 1][N], sm[N << 1];

struct Edge {
  int v, nxt, f;
} e[N * N << 1];

inline void add(int u, int v, int f) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt, e[e_cnt].f = f;
  e[++e_cnt].v = u, e[e_cnt].nxt = heads[v], heads[v] = e_cnt, e[e_cnt].f = 0;
}

inline bool bfs() {
  queue<int> q;
  memset(dis, 0, sizeof(dis));
  q.push(s);
  dis[s] = 1;
  memcpy(cur, heads, sizeof(cur));
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = heads[u], v; i; i = e[i].nxt)
      if (e[i].f && !dis[v = e[i].v]) dis[v] = dis[u] + 1, q.push(v);
  }
  return dis[t];
}

inline void modify(int x, int y) {
  for (int i = x; i != y; i = e[f[i]].v) e[f[i]].f = 1, e[f[i] ^ 1].f = 0;
}

int dinic(int u, int flow) {
  if (u == t) return flow;
  int k, rest = flow;
  for (int &i = cur[u], v; i && rest; i = e[i].nxt) {
    if (dis[v = e[i].v] == dis[u] + 1 && e[i].f) {
      k = dinic(v, min(rest, e[i].f));
      rest -= k, e[i].f -= k;
      e[i ^ 1].f += k;
      if (!k) dis[v] = 0;
    }
  }
  return flow - rest;
}

int maxflow() {
  int res = 0;
  while (bfs()) res += dinic(s, INF);
  return res;
}

inline bool match(int s, int t) {
  queue<int> q;
  memset(dis, 0, sizeof(dis));
  q.push(s);
  dis[s] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = heads[u], v; i; i = e[i].nxt)
      if (e[i].f && !vis[v = e[i].v] && !dis[v])
        dis[v] = dis[u] + 1, q.push(v), f[v] = i ^ 1;
  }
  return dis[t];
}

inline int main() {
  cin >> n;
  s = 0, t = n * 2 + 1;
  for (int i = 1; i <= n * 2; ++i)
    for (int j = 1; j <= n; ++j) cin >> a[i][j];
  for (int i = 1; i <= n; ++i) c[i][i] = 1, add(s, i, 1), add(i + n, t, 1);
  for (int i = 1; i <= n; ++i) {
    double mx = 0;
    int pos;
    for (int j = 1; j <= 2 * n; ++j)
      if (!vis[j]) {
        sm[j] = 0;
        for (int k = 1; k <= n; ++k) sm[j] += c[j][k] * a[k][i];
        if (j <= n) {
          if (abs(sm[j]) > mx) mx = abs(sm[j]), pos = j;
        } else
          sm[j] += a[j][i];
      }
    if (mx < eps) {
      cout << "NIE";
      return 0;
    }
    vis[pos] = true;
    for (int j = 1; j <= 2 * n; ++j)
      if (!vis[j] && abs(sm[j]) > eps)
        for (int k = 1; k <= n; ++k) c[j][k] -= c[pos][k] * sm[j] / sm[pos];
  }
  for (int j = 1; j <= n; ++j)
    for (int i = n * 2; i > n; --i)
      if (abs(c[i][j]) > eps) add(j, i, 1);
  memset(vis, 0, sizeof(vis));
  if (maxflow() < n) {
    cout << "NIE";
    return 0;
  }
  cout << "TAK\n";
  vis[t] = true;
  for (int i = 1; i <= n; ++i)
    for (int j = heads[i], v; j; j = e[j].nxt) {
      if ((v = e[j].v) != s && !vis[v] && (!e[j].f || match(v, i))) {
        cout << v - n << '\n';
        vis[v] = true;
        if (e[j].f) modify(i, v), e[j].f = 0, e[j ^ 1].f = 1;
        break;
      }
    }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P4100 [HEOI2013] 钙铁锌硒维生素.in", "r", stdin);
  freopen("P4100 [HEOI2013] 钙铁锌硒维生素.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
